package com.swing.dome;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;

/**
 * @author Yuang, Gongming
 * @date 2022-02-09 10:30
 */
public class LanguageBroadcasts {
    public static void main(String[] args) {

        ActiveXComponent sap = new ActiveXComponent("Sapi.SpVoice");

        try {

            // 音量 0-100
            sap.setProperty("Volume", new Variant(100));

            // 语音朗读速度 -10 到 +10
            sap.setProperty("Rate", new Variant(0));

            // 获取执行对象
            Dispatch sapo = sap.getObject();

            // 执行朗读 kangkang yaoyao
            Dispatch.call(sapo, "Speak", new Variant("你已选择Microsoft huihui作为默认语音！"));
            Thread.sleep(1000);
            Dispatch.call(sapo, "Speak", new Variant("你好（袁先生），很高兴见到你！吃过饭了没有?"));
            Thread.sleep(1000);
            Dispatch.call(sapo, "Speak", new Variant("我吃过了，我现在有事等会聊吧！"));
            Thread.sleep(1000);
            Dispatch.call(sapo, "Speak", new Variant("Camel xiangzi is the representative work of Lao she in Beijing a rickshaw pullers shoko's whereabouts, in the late 20 s as the background, the citizens of Beijing life by rickshaw pullers shoko bumpy, miserable life experience as the main plot, profoundly revealed an era of extrusion, and the general public condition expressed the author's deep sympathy for working people showed the underlying lean Bitter people positive efforts to change the fate, but big trouble. Camel xiangzi was one of the excellent works in China in the decade, it laid the important position in the history of Chinese modern literature, Lao she's camel xiangzi is his personal and important works of Chinese modern literature."));

            // 关闭执行对象
            sapo.safeRelease();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // 关闭应用程序连接
            sap.safeRelease();
        }

    }

}
